<template>
  <el-dropdown @command="changeLanguage">
    <div>
      <svg-icon style="color: #fff; font-size: 30px" icon-class="language" />
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="zh">中文</el-dropdown-item>
      <el-dropdown-item command="en">en</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookie from 'js-cookie'
export default {
  methods: {
    changeLanguage(type) {
      // console.log(type)
      // 切换的语言类型存储到cookie，进行持久化存储
      // 下一次刷新的时候依旧保存着上一次切换的结果
      Cookie.set('lan', type)
      this.$i18n.locale = type
    }
  }
}
</script>
